﻿using System;
using System.Collections.Generic;
using System.Text;
using SwinGame;

namespace Survivor.src
{
    class Textbox
    {
        
        Point2D _pos;
        Point2D _size;
        bool _hidden;
        string _name;

        public Point2D Size
        {
            get { return _size; }
            set { _size = value; }
        }

        public Point2D Pos
        {
            get { return _pos; }
            set { _pos = value; }
        }

        public bool isHidden
        {
            get { return _hidden; }
            set { _hidden = value; }
        }

        string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public Textbox(int posX, int posY, int sizeX, int sizeY, string name)
        {
            _pos.X = posX;
            _pos.Y = posY;
            _size.X = sizeX;
            _size.Y = sizeY;
            _name = name;
        }

        bool containsPoint(Point2D p)
        {
            return p.InRect(Pos.X, Pos.Y, Size.X, Size.Y);
        }

        public bool isPressed()
        {
            return Input.MouseClicked(MouseButton.LeftButton) && containsPoint(Input.MousePosition()) && isHidden == false;
            
        }

        public void Draw()
        {
            if (!isHidden)
            {
                Graphics.DrawRectangleOnScreen(System.Drawing.Color.Black, false, (int)Pos.X, (int)Pos.Y, (int)Size.X, (int)Size.Y);
                SwinGame.Text.DrawText(Name, System.Drawing.Color.Black, Pos);
            }
        }
    }
}
